---
title: "Reference: MastraAuthSupabase Class | Auth"
description: "API reference for the MastraAuthSupabase class, which authenticates Mastra applications using Supabase Auth."
---

# MastraAuthSupabase Class

The `MastraAuthSupabase` class provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the `auth` option.

## Usage example

```typescript title="src/mastra/index.ts" showLineNumbers copy
import { Mastra } from "@mastra/core";
import { MastraAuthSupabase } from "@mastra/auth-supabase";

export const mastra = new Mastra({
  // ..
  server: {
    auth: new MastraAuthSupabase({
      url: process.env.SUPABASE_URL,
      anonKey: process.env.SUPABASE_ANON_KEY,
    }),
  },
});
```

## Constructor parameters

<PropertiesTable
  content={[
    {
      name: "url",
      type: "string",
      description:
        "The URL of your Supabase project. Can be found in your Supabase project settings.",
      isOptional: true,
      defaultValue: "process.env.SUPABASE_URL",
    },
    {
      name: "anonKey",
      type: "string",
      description:
        "The anonymous/public key for your Supabase project. Used for client-side authentication.",
      isOptional: true,
      defaultValue: "process.env.SUPABASE_ANON_KEY",
    },
    {
      name: "name",
      type: "string",
      description: "Custom name for the auth provider instance.",
      isOptional: true,
    },
    {
      name: "authorizeUser",
      type: "(user: User, request: HoneRequest) => Promise<boolean> | boolean",
      description:
        "Custom authorization function to determine if a user should be granted access. Called after token verification. By default, checks the 'isAdmin' column in the 'users' table.",
      isOptional: true,
    },
  ]}
/>

## Related

[MastraAuthSupabase](/docs/v1/auth/supabase)
